#include"head.h"

LD getrandom() {
	std::random_device rd;
	std::mt19937 gen(rd());
	std::normal_distribution<> d(0.0, 0.01);
	return d(gen);
}

LD sigmoid(LD x) {
	return 1 / (1 + exp(-x));
}

LD sigmoidDelta(LD x) {
	return sigmoid(x) * (1 - sigmoid(x));
}

LD calLoss(std::vector<LD>& pridic, std::vector<LD>& actual) {
	LD temp = 0;

	for (size_t i = 0; i < pridic.size(); i++) {
		temp += -(actual[i] * log(pridic[i]) + (1 - actual[i]) * log(1 - pridic[i]));
	}
	return temp / (pridic.size());
}